# -*- coding:utf8 -*-
import matplotlib
import matplotlib.pyplot as plt

# 绘制损失曲线
import numpy as np

matplotlib.use('TkAgg')
# 假设的迭代次数
iterations = [i for i in range(910)]
print(iterations)

# 假设的损失值，逐渐减小
loss_values = [0.8, 0.6, 0.5, 0.4, 0.3, 0.2, 0.15, 0.1, 0.05, 0.03] + [0.01] * 900
loss_values2 = [0.8, 0.6, 0.5, 0.4, 0.3, 0.2, 0.15, 0.1, 0.05, 0.03] + [0.02] * 900

plt.figure(figsize=(10, 6))
plt.plot(iterations, loss_values, label='loss1')
plt.plot(iterations, loss_values2, label='loss2')
plt.xlabel('step')
plt.ylabel('loss')
plt.title('loss info')
plt.legend()
plt.grid(True)
plt.show()


def draw2(datas):
    np.random.seed(0)  # 确保每次运行代码时结果相同
    num_curves = 1

    # 生成随机损失曲线
    loss_curves = []
    for i in range(num_curves):
        # noise = np.random.normal(0, 0.1, 1000)
        # curve = np.logspace(-1, -3, 100) + noise
        curve = np.sin(np.linspace(0, 2, 100))
        loss_curves.append(curve)

    # 绘制多条损失曲线
    plt.figure(figsize=(10, 6))
    for i, curve in enumerate(loss_curves):
        iterations = np.arange(len(curve))
        plt.plot(iterations, curve, label=f'model {i + 1}')

    plt.xlabel('steps')
    plt.ylabel('loss')
    plt.title('loss info')
    plt.legend()
    plt.grid(True)
    plt.show()